package com.hducms.cms.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hducms.cms.service.CmsUserExtService;
import com.hducms.cms.dao.CmsUserExtDao;
import com.hducms.cms.entity.main.CmsUser;
import com.hducms.cms.entity.main.CmsUserExt;
//import com.hducms.cms.manager.main.CmsUserExtMng;

@Service
@Transactional
public class CmsUserExtServiceImpl implements CmsUserExtService {
	public CmsUserExt save(CmsUserExt ext, CmsUser user) {
		ext.blankToNull();
		ext.setId(user.getUserId());
		ext.setUser(user);
		dao.save(ext);
		return ext;
	}

	public CmsUserExt update(CmsUserExt ext, CmsUser user) {
		ext.setId(user.getUserId());
		dao.update(ext);
		return ext;
	}
	
	@Override
	public void updateFaceById(String personId,int userId,int faceCount) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("personId", personId);
		params.put("uerId", userId);
		params.put("faceCount", faceCount);
		dao.updateFaceById(params);
	}

	private CmsUserExtDao dao;

	@Autowired
	public void setDao(CmsUserExtDao dao) {
		this.dao = dao;
	}

	@Override
	public CmsUserExt findById(int id) {
		return dao.findById(id);
	}

}